﻿using OverStore.Runtime.Storage;

namespace OverStore.Runtime.ObjectRepository.IdentifierProvider
{
    /// <summary>
    /// Get identifier for instance from data represented by <see cref="IRecord"/>.
    /// </summary>
    /// <typeparam name="TIdentifier">The type of the identifier.</typeparam>
    /// <remarks>
    /// ReadIdentifier Provider used by Object Reader and Object Repository. In object reader it used for obtain identifier for each read row of data.
    /// In object repository identifier provider used for obtain new identifier after saving instance. Object repository uses data storage command
    /// output to extract and update instance identifier.
    /// </remarks>
    public interface IIdentifierProvider<TIdentifier> : IRuntimeComponent
    {
        /// <summary>
        /// Gets the identifier from data specified.
        /// </summary>
        /// <param name="data">The data to get identifier from.</param>
        /// <returns>The identifier.</returns>
        /// <exception cref="PersistingRuntimeException">The error occures during gets identifier from set of data.</exception>
        TIdentifier GetIdentifier(TypedRecord data);
    }
}
